package org.msn.rest;

import lombok.Builder;
import lombok.Data;

import java.util.HashMap;

@Data
@Builder
public class RestResult {
    private int code;
    private String msg;
    private Object data;

    public RestResult(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public RestResult(RestCode restCode, Object data) {
        this.code = restCode.getCode();
        this.msg = restCode.getMsg();
        this.data = data;
    }

    public RestResult(RestCode restCode) {
        this.code = restCode.getCode();
        this.msg = restCode.getMsg();
        this.data = new HashMap();
    }

    public RestResult() {
    }

    public RestResult setRestCode(RestCode restCode) {
        this.code = restCode.getCode();
        this.msg = restCode.getMsg();
        return this;
    }
}
